#ifndef _EBN_MODEL_THREAD_H_
#define _EBN_MODEL_THREAD_H_

#include <QObject>
#include <vector>

class CEbnModel;
class CEbnWorldStateManager;
class CEbnActionManager;
class CEbnModelFactory;

using namespace std;

class CEbnActionTrigger
{
public:
    CEbnActionTrigger(string actionName, string worldStateName, float truthValue);
    ~CEbnActionTrigger(void);

    string getActionName(void);
    string getWorldStateName(void);
    float getTruthValue(void);

    bool isAction(string actionName);
    bool isWorldState(string worldStateName);

private:
    string mActionName;
    string mWorldStateName;
    float mTruthValue;
};

class CEbnModelController : public QObject
{
    Q_OBJECT
public:
    CEbnModelController(QObject * parent = 0);
    ~CEbnModelController(void);
    virtual void initializeModel(void);
    virtual void uninitializeModel(void);

    void addActionTrigger(string actionName, string worldStateName, float truthValue);
    void removeActionTrigger(string actionName, string worldStateName);
    void clearActionTrigger(void);
    float getActionTriggerValue(string actionName, string worldStateName);
    CEbnActionTrigger * getActionTrigger(string actionName, string worldStateName);
    bool hasActionTrigger(string actionName, string worldStateName);

    void start(void);
    void stop(void);

    void run(void);
    void pause(void);

    void loadModelFile(const QString & filename);

    CEbnModel * getModel(void) { return mpModel; }
    CEbnWorldStateManager * getWorldStateManager(void) { return mpWorldStateManager; }
    CEbnActionManager * getActionManager(void) { return mpActionManager; }

protected:
    virtual void onMsgReceived(string msgName);

    void doActionTrigger(string actionName);

signals:

    void postMsg(string msgName);

public slots:

    void receiveMsgFromModel(string msgName);


protected:

    CEbnModel * mpModel;
    CEbnWorldStateManager * mpWorldStateManager;
    CEbnActionManager * mpActionManager;
    CEbnModelFactory * mpModelFactory;

private:
    bool mControllerStarted;
    bool mControllerRunning;

    vector<CEbnActionTrigger *> mActionTriggerList;


};

#endif // _EBN_MODEL_THREAD_H_
